<?php
class CAuctionPoolBehavior extends CActiveRecordBehavior{    
    
    public $auctionIdAttribute;
    public $startTimeAttribute;
    public $endTimeAttribute;
    public $winnerPriceIncrementAttribute;
    public $winnerPrice;
    
    public function afterSave($event){
        if ($this->getOwner()->getIsNewRecord()) {
            $auctionPool = new AuctionPool();
            $auctionPool->attributes = array(
                'auction_id'    => $this->getOwner()->{$this->auctionIdAttribute},
                'start_time'    => $this->getOwner()->{$this->startTimeAttribute},
                'end_time'      => $this->getOwner()->{$this->endTimeAttribute},
                'winner_price_increment' => $this->getOwner()->{$this->winnerPriceIncrementAttribute},
                'winner_price_increment' => $this->getOwner()->{$this->winnerPrice},
            );
            if ($this->getOwner()->{$this->startTimeAttribute}< time()){
                $auctionPool->status = 1;
            }
            $auctionPool->save();
        }
    }
    
}